
class PriorityQueue:
    def __init__(self):
        self.list = []
    def push(self, node):
        for i in range(len(self.list)):
            if node.cost < self.list[i].cost:
                self.list.insert(i, node)
                return
        self.list.append(node)
    def change(self, node):
        for i in range(len(self.list)):
            if node.node.idx == self.list[i].node.idx:
                del(self.list[i])
                break
        self.push(node)
    def pop(self):
        return self.list.pop(0)
    def __len__(self):
        return len(self.list)

